﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// Fwmmszbt数据类
    /// </summary>
    public class Fwmmszbt
    {

        /// <summary>
        /// 组织机构DAL
        /// </summary>
        private readonly DAL.Fwmmszbt dal = new DAL.Fwmmszbt();
        /// <summary>
        /// 得到列表
        /// </summary>
        /// <param name="where">where条件</param>
        /// <returns>数据列表</returns>
        public DataSet GetAllList(string where)
        {
            return dal.GetAllList(where);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public DataSet GetChangeData(string where)
        {
            return dal.GetChangeData(where);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="day"></param>
        /// <returns></returns>
        public DataSet GetData(string day)
        {
            return dal.GetData(day);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model对象</param>
        /// <returns>增加的数目</returns>
        public decimal Add(ElingOA6_Admin_DSJCJ.Model.Fwmmszbt model)
        {
            return dal.Add(model);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model对象</param>
        /// <returns>是否更新成功</returns>
        public bool Update(ElingOA6_Admin_DSJCJ.Model.Fwmmszbt model)
        {
            return dal.Update(model);
        }
        /// <summary>
        /// 批量删除数据 
        /// <creator>chenly</creator>
        /// <date>2013-8-1</date>
        /// </summary>
        /// <param name="idArray">id数组</param>
        public void DeleteMany(string[] idArray)
        {
            dal.DeleteMany(idArray);
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-12</date>       
        /// <param name="sfz">身份证</param>
        /// <returns>是否存在</returns>
        public bool Exists(string sfz)
        {
            return dal.Exists(sfz);
        }

        /// <summary>
        /// 得到一个对象实体
        /// <creator>chenly</creator>
        /// <date>2013-8-1</date>
        /// </summary>
        /// <param name="id">主键</param> 
        /// <returns>返回Model</returns>
        public Model.Fwmmszbt GetModel(decimal id)
        {
            return dal.GetModel(id);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>是否删除</returns>
        public bool Delete(decimal id)
        {
            return dal.Delete(id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="dt">行</param>
        /// <returns>数据集合</returns>
        public List<Model.Fwmmszbt> DataTableToListFwmmszbtz(DataTable dt)
        {
            List<Model.Fwmmszbt> modelList = new List<Model.Fwmmszbt>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.Fwmmszbt model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Fwmmszbt();

                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = decimal.Parse(dt.Rows[n]["id"].ToString());
                    } if (dt.Rows[n]["bh"] != null && dt.Rows[n]["bh"].ToString() != "")
                    {
                        model.bh = int.Parse(dt.Rows[n]["bh"].ToString());
                    }
                    if (dt.Rows[n]["nsr"] != null && dt.Rows[n]["nsr"].ToString() != "")
                    {
                        model.nsr = dt.Rows[n]["nsr"].ToString();
                    }
                    if (dt.Rows[n]["sfz"] != null && dt.Rows[n]["sfz"].ToString() != "")
                    {
                        model.sfz = dt.Rows[n]["sfz"].ToString();
                    }
                    if (dt.Rows[n]["yjsk"] != null && dt.Rows[n]["yjsk"].ToString() != "")
                    {
                        model.yjsk =decimal.Parse(dt.Rows[n]["yjsk"].ToString());
                    }
                    if (dt.Rows[n]["btbl"] != null && dt.Rows[n]["btbl"].ToString() != "")
                    {
                        model.btbl = decimal.Parse(dt.Rows[n]["btbl"].ToString());
                    }
                    if (dt.Rows[n]["ybtse"] != null && dt.Rows[n]["ybtse"].ToString() != "")
                    {
                        model.ybtse = decimal.Parse(dt.Rows[n]["ybtse"].ToString());
                    }
                    if (dt.Rows[n]["khyh"] != null && dt.Rows[n]["khyh"].ToString() != "")
                    {
                        model.khyh = dt.Rows[n]["khyh"].ToString();
                    }

                    if (dt.Rows[n]["zh"] != null && dt.Rows[n]["zh"].ToString() != "")
                    {
                        model.zh = dt.Rows[n]["zh"].ToString();
                    }
                    if (dt.Rows[n]["btrq"] != null && dt.Rows[n]["btrq"].ToString() != "")
                    {
                        model.btrq = DateTime.Parse(dt.Rows[n]["btrq"].ToString());
                    }
                    if (dt.Rows[n]["sz"] != null && dt.Rows[n]["sz"].ToString() != "")
                    {
                        model.sz = dt.Rows[n]["sz"].ToString();
                    }

                    modelList.Add(model);
                }
            }
            return modelList;
        }

    }
}
